<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;
function myfile_onchange(){	//复制文件
    var files=document.getElementById("myfile").files; 
    window.requestFileSystem( PERSISTENT, 1024,  
        function(fs){	//请求文件系统成功时所执行的回调函数
            for(var i = 0, file; file = files[i]; ++i){
                (function(f) {
                    fs.root.getFile(file.name, {create: true}, function(fileEntry) {
                        fileEntry.createWriter(function(fileWriter) {
                            fileWriter.onwriteend = function(e) {
                                document.getElementById("result").innerHTML+='复制文件名为：'+f.name+'<br/>';
                            };
                            fileWriter.onerror = errorHandler
                            fileWriter.write(f); 
                        }, errorHandler);
                    }, errorHandler);
                })(file); 
            } 
        }, 
        errorHandler  	//请求文件系统失败时所执行的回调函数
    );
}
function errorHandler(e) {
    //省略代码
}
</script>
</head>
<body>
<h1>复制文件</h1>
<input type="file" id="myfile" onchange="myfile_onchange()" multiple /><br>   
<output id="result" ></output>
</body>
</html> 
